using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using OpenFaq.AcceptanceTests.StepHelpers;
using TechTalk.SpecFlow;
using WatiN.Core;


namespace OpenFaq.AcceptanceTests.Steps
{
    [Binding]
    public class Register
    {

		[When(@"I enter a random username and email")]
        public void WhenIEnterARandomUsernameAndEmail()
        {
            var usernameField = WebBrowser.Current.TextField(Find.ByName("UserName"));

            if (!usernameField.Exists)
                Assert.Fail(string.Format("Could not find {0} field on the page", usernameField));

            var randomUsername = "acceptance_test_username_" + DateTime.Now.Ticks;
            usernameField.TypeText(randomUsername);

			var emailField = WebBrowser.Current.TextField(Find.ByName("Email"));
			if (!emailField.Exists)
				Assert.Fail(string.Format("Could not find {0} field on the page", emailField));

			emailField.TypeText(randomUsername + "@test.com");
        }

    }
}